package tt.dz.util.annotation;

import tt.dz.entity.charger.OmsCharger;

/**
 * Created by Administrator on 2016/4/19.
 */
public class SNUtils
{
	public static String convertToAsciiDesc(String origin)
	{
		StringBuffer sb = new StringBuffer("");

		for (int i = 0; i < origin.length(); i = i + 2)
		{
			String hex = origin.substring(origin.length() - i - 2, origin.length() - i);
			int ascii = Integer.valueOf(hex, 16);
			char c = (char) ascii;
			sb.append(c);
		}

		return sb.toString();
	}

	public static String convertToAscii(String origin)
	{
		StringBuffer sb = new StringBuffer("");

		for (int i = 0; i < origin.length(); i = i + 2)
		{
			String hex = origin.substring(i, i + 2);
			int ascii = Integer.valueOf(hex, 16);
			char c = (char) ascii;
			sb.append(c);
		}

		return sb.toString();
	}

	public static void main(String[] args)
	{
		System.out.println(convertToAsciiDesc("ABCDEF2039874512"));
		System.out.println(convertToAsciiDesc("45670123"));

		OmsCharger c = new OmsCharger();

	}
}
